package com.woniuxy.elasticsearch;

import com.woniuxy.elasticsearch.entity.Goods;
import com.woniuxy.elasticsearch.mapper.GoodsMapper;
import org.junit.jupiter.api.Test;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.data.domain.PageRequest;
import org.springframework.data.domain.Pageable;

import javax.annotation.Resource;
import java.util.List;

/**
 * @Author zhangyong
 * @Date 2021/8/17 0017上午 9:46
 */
@SpringBootTest
public class CustomQuery {
    @Resource
    private GoodsMapper goodsMapper;

    @Test
    public void findByName(){
        //
        Pageable pageable = PageRequest.of(1,10 );
        //
        List<Goods> goods = goodsMapper.findByName("IT",pageable);
        //
        System.out.println(goods.size());
    }

    @Test
    public void findByNameAndSalesprice(){
        List<Goods> goods = goodsMapper.findByNameAndSalesprice("IT", 1.0);
        System.out.println(goods);
    }

    @Test
    public void findByNameOrSalesprice(){
        List<Goods> goods = goodsMapper.findByNameOrSalesprice("1.0");
        System.out.println(goods);

    }

    @Test
    public void findBySalespriceBetween(){
        List<Goods> goods = goodsMapper.findBySalespriceBetween(1.0, 9.0);
        System.out.println(goods);
    }

    @Test
    public void findBySalespriceLessThan(){
        List<Goods> goods = goodsMapper.findBySalespriceLessThan(100);
        System.out.println(goods);

    }
}
